package main

import (
	"strings"
	"fmt"
)

func main() {
	s := `this is a string`

	//包含字符串判断
	b := strings.Contains(s, "this")
	fmt.Printf("%v\n", b)

	//字符串连接
	s1 := []string{"this", "is", "a", "string"}
	str := strings.Join(s1, "_")
	fmt.Printf("%v\n", str)

	//Index 查找位置
	fmt.Printf("%v\n", strings.Index(s, "is"))

	//repeat
	fmt.Printf("%v\n", strings.Repeat(s, 2))

	//trim
	s3 := "   this   is  a  string    "
	fmt.Printf("#%v#\n",strings.Trim(s3," "))

	//Fields 去掉空格，把元素放入切片中
	fmt.Printf("%v\n",strings.Fields(s3))
}
